package com.dx.hsb.test;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName Student
 * @Description TODO:
 * @Author 12994
 * @Date 2024/10/22 20:56
 * @Version 1.0
 **/
public class Student {
    public String name;
    public double age;

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    public Student(String name, double age) {
        this.name = name;
        this.age = age;
    }

    public static void main(String[] args) {
        Student[] students = new Student[4];
        Student tempStu = null;
        students[0] = new Student("小1", 3D);
        students[1] = new Student("小2", 6D);
        students[2] = new Student("小3", 1D);
        students[3] = new Student("小4", 5D);
        for (int i = 0; i < students.length - 1; i++) {
            for (int j = 0; j < students.length - 1 - i; j++) {
                if (students[j].age > students[j + 1].age) {
                    tempStu = students[j];
                    students[j] = students[j + 1];
                    students[j + 1] = tempStu;
                }
            }
        }

        for (Student student : students) {
            System.out.println(student);
        }
    }
}
